//
//  ProductCategoryModel.swift
//
//  Created by eme on 2016/12/13
//  Copyright (c) . All rights reserved.
//

import Foundation
import SwiftyJSON
import ModelProtocol

/// 商品分类
class ProductCategoryModel: ModelProtocol {
    
    // MARK: Declaration for string constants to be used to decode and also serialize.
    internal let kProductCategoryPptremarkKey: String = "pptremark"
    internal let kProductCategoryPpturlKey: String = "ppturl"
    internal let kProductCategoryPptnameKey: String = "pptname"
    internal let kProductCategoryPptypeKey: String = "pptype"
    internal let kProductCategoryPptdelflagKey: String = "pptdelflag"
    internal let kProductCategoryPptimgKey: String = "pptimg"
    internal let kProductCategoryAppcodeKey: String = "appcode"
    internal let kProductCategoryPptorderKey: String = "pptorder"
    internal let kProductCategoryPptidKey: String = "pptid"
    
    
    // MARK: 属性
    var pptremark: String
    var ppturl: String
    var pptname: String
    //`pptype`'分类类型(0-不关联1-关联商品分类2-固定链接3-关键字)'
    var pptype: String
    var pptdelflag: String
    var pptimg: String
    var appcode: String
    var pptorder: Int
    var pptid: Int
    
    
    // MARK: 实现MikerSwiftJSONAble 协议， 解析json数据
    required  init?(json: JSON) {
        pptremark = json[kProductCategoryPptremarkKey].stringValue
        ppturl = json[kProductCategoryPpturlKey].stringValue
        pptname = json[kProductCategoryPptnameKey].stringValue
        pptype = json[kProductCategoryPptypeKey].stringValue
        pptdelflag = json[kProductCategoryPptdelflagKey].stringValue
        pptimg = json[kProductCategoryPptimgKey].stringValue
        appcode = json[kProductCategoryAppcodeKey].stringValue
        pptorder = json[kProductCategoryPptorderKey].intValue
        pptid = json[kProductCategoryPptidKey].intValue
        
    }
    
    
    /**
     Generates description of the object in the form of a NSDictionary.
     - returns: A Key value pair containing all valid values in the object.
     */
    internal func dictionaryRepresentation() -> [String : AnyObject ] {
        
        var dictionary: [String : AnyObject ] = [ : ]
        
        dictionary.updateValue(pptremark as AnyObject, forKey: kProductCategoryPptremarkKey)
        
        dictionary.updateValue(ppturl as AnyObject, forKey: kProductCategoryPpturlKey)
        
        dictionary.updateValue(pptname as AnyObject, forKey: kProductCategoryPptnameKey)
        
        dictionary.updateValue(pptype as AnyObject, forKey: kProductCategoryPptypeKey)
        
        dictionary.updateValue(pptdelflag as AnyObject, forKey: kProductCategoryPptdelflagKey)
        
        dictionary.updateValue(pptimg as AnyObject, forKey: kProductCategoryPptimgKey)
        
        dictionary.updateValue(appcode as AnyObject, forKey: kProductCategoryAppcodeKey)
        
        dictionary.updateValue(pptorder as AnyObject, forKey: kProductCategoryPptorderKey)
        
        dictionary.updateValue(pptid as AnyObject, forKey: kProductCategoryPptidKey)
        
        
        return dictionary
    }
    
    
}
